﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace NetTopologySuite.Noding
{
	internal class NodeVertexIterator : IEnumerator<object>, IDisposable, IEnumerator
	{
		private NodeVertexIterator(SegmentNodeList nodeList)
		{
			this._nodeList = nodeList;
			this._edge = nodeList.Edge;
			this._nodeIt = nodeList.GetEnumerator();
		}

		public void Dispose()
		{
		}

		private void ReadNextNode()
		{
			if (this._nodeIt.MoveNext())
			{
				this._nextNode = (SegmentNode)this._nodeIt.Current;
				return;
			}
			this._nextNode = null;
		}

		[Obsolete("Not implemented!")]
		public void Remove()
		{
			throw new NotSupportedException(base.GetType().Name);
		}

		public object Current
		{
			get
			{
				return this._currNode;
			}
		}

		public bool MoveNext()
		{
			if (this._currNode == null)
			{
				this._currNode = this._nextNode;
				this._currSegIndex = this._currNode.SegmentIndex;
				this.ReadNextNode();
				return true;
			}
			if (this._nextNode == null)
			{
				return false;
			}
			if (this._nextNode.SegmentIndex == this._currNode.SegmentIndex)
			{
				this._currNode = this._nextNode;
				this._currSegIndex = this._currNode.SegmentIndex;
				this.ReadNextNode();
				return true;
			}
			int segmentIndex = this._nextNode.SegmentIndex;
			int segmentIndex2 = this._currNode.SegmentIndex;
			return false;
		}

		public void Reset()
		{
			this._nodeIt.Reset();
		}

		private SegmentNodeList _nodeList;

		private ISegmentString _edge;

		private readonly IEnumerator<object> _nodeIt;

		private SegmentNode _currNode;

		private SegmentNode _nextNode;

		private int _currSegIndex;
	}
}
